package com.ailk.aee.pcc.action;

import com.ailk.aee.pcc.server.UserPloyServer;
import com.asiainfo.appserver.Action;
import com.asiainfo.appserver.Request;
import com.asiainfo.appserver.Response;
import com.asiainfo.appserver.annotations.Function;
import com.asiainfo.appserver.annotations.Parameter;
import com.asiainfo.appserver.annotations.Type;
import com.mongodb.DBObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 查询用户是否在策略内
 *
 * @author chenchao
 */
@Function(
        description = "查询用户策略数据", parameters = {
        @Parameter(name = "userId", type = Type.String, description = "用户ID", required = true),
        @Parameter(name = "ployId", type = Type.String, description = "策略id", required = true)

})
@Component
public class QueryUserPloy implements Action {

    @Autowired
    private UserPloyServer userPloyServer;


    @Override
    public Response execute(Request request) throws Exception {

        String userId = request.getString("userId").trim();
        String ployId = request.getString("ployId").trim();

        boolean  flag  = userPloyServer.isInvoled(userId,ployId);

        Response response = new Response();
        response.put("result", flag);

        return response;
    }
}
